const users=require("../model/user");

module.exports=function(req,res){

    var data={...req.query,...req.body};
    
    users.findOne({userName:data.username}).then((result)=>{
        if(result){
            res.send({
                code:1,
                msg:"该用户已注册,请重新输入"
            })
        }else{
            
            if(data.username==="ym深"){//管理员名称
                users.create({
                    userName:data.username,
                    password:data.password,
                    isAdmin:true
                });
            }else{
                users.create({
                    userName:data.username,
                    password:data.password
                });
            }
            res.send({
                code:0,
                msg:"注册成功，即将跳转到登陆窗口"
            })
        }
    })



}